home *** CD-ROM | disk | FTP | other *** search
- Path: EU.net!sun4nl!xs4all!falstaff
- From: falstaff@xs4all.nl (Falstaff)
- Newsgroups: comp.lang.c
- Subject: Re: integer and real numbers in C/C++
- Date: 14 Mar 1996 20:03:36 GMT
- Organization: XS4ALL, networking for the masses
- Message-ID: <4i9u2o$1a9@news.xs4all.nl>
- References: <31477D44.782@macon.wm.slb.com>
- NNTP-Posting-Host: xs1.xs4all.nl
- X-Newsreader: NN version 6.5.0 #666 (NOV)
-
- Laurent Darton <darton@macon.wm.slb.com> writes:
-
- >Hi every all,
- >According to IEEE 754, I can use integer coded on 24 bits (3 Bytes),
- >integer coded on 48 bits (6 Bytes) and on 64 bits...
-
- IEEE754 is a *floating point* standard.
-
- >How can I declare those values in C... I suppose I need to create new
- >data structures to do that.. But I don't know how to do ...
- > My compiler (MSVC 1.52) says :
- >long=4 Bytes
-
- float is 4 bytes
-
- >double =8 Bytes
- >long double =10 Bytes
-
- >My problem is
- > - I don't want to use a long (4 Bytes) to code 3 bytes (but it
- >works fine..)
- > - I cannot code an integer with 8 Bytes (but only a double..)
-
- What's the problem in using a long for a 24-bit integer? Your computer
- would be able to handle 32-bit numbers faster than 24-bit ones.
-
- Of course, if you're storing data in binary form in files, you could
- chop off the unwanted bits by
-
- fputc((Num>>16)&0xff,outFile);
- fputc((Num>>8)&0xff,outFile);
- fputc(Num&0xff,outFile);
-
- (those ANDs are there only for clarity, not really needed as the
- implicit conversions involved will simply throw away higher-order
- bits anyway).
-
- Frank
- --
- The famous GIICM now on line: http://www.xs4all.nl/~falstaff/GIICM.html
- ------------------------------------------------------------------------
- Frank A. Vorstenbosch +31-(70)-355 5241 falstaff@xs4all.nl
-